package com.作业.第八章作业.HomeWork13;

public class main {
    public static void main(String[] args) {
        Student student1 = new Student("张三", 18, "男", 101);
        System.out.println(student1.play());
        Teacher teacher = new Teacher("李四", 50, "男", 10);
        System.out.println(teacher.play());
        System.out.println("==============================================");


        System.out.println(student1.printinfo());
        System.out.println("==============================================");
        System.out.println(teacher.printinfo());




        Person person[] = new Person[4];
        person[0] = student1;
        person[1] = new Student("王五", 13, "男",102);
        person[2] = teacher;
        person[3] = new Teacher("赵六", 40, "男", 10);
        System.out.println("==============================================");




        for (int i = 0;  i < person.length; i++) {
            System.out.println(person[i].show());
        }

        System.out.println("==============================================");



        new Sort().sort(person);  //把冒泡排序封装成 方法




        for (int i = 0; i < person.length; i++) {
            System.out.println(person[i].show());
            person[i].fangfa(person[i]);
        }



    }
}


class Sort{
    public void sort(Person[] person){
        for (int i = 0; i < person.length-1; i++) {
            for (int j = 0; j < person.length-1-i; j++) {
                if(person[j].getAge()<person[j+1].getAge()){
                    Person temp = person[j];
                    person[j] = person[j+1];
                    person[j+1] = temp;
                }
            }
        }
    }


}